package io.BufferedStream;

import java.io.*;

public class BufferedInputStreamDemo {
    public static void main(String[] args) throws IOException {
    /*

        利用字节缓冲流拷贝文件
     */
//        1.创建文件对象
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("b.txt"));
//        将b.txt的文件拷贝到a.txt内
        BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("a.txt"));
//      循环读取获取数据
        int b;
        while((b=bis.read())!=-1){
            bos.write(b);
        }
            bos.close();
            bis.close();
/*
//            一次读取多个字节
        byte[]bytes=new byte[1024];
        int len;
        while ((len=bis.read(bytes))!=-1){
            bos.write(bytes);
        }
        bos.close();
        bis.close();*/
    }
}
